package com.dyh.lvup.byteBuddy;

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.FixedValue;

import static net.bytebuddy.matcher.ElementMatchers.named;

/*
@Author=Joey Wheeler
@Date=2021/3/1 15:27
*/
public class Hello {
    public static void main(String[] args) throws IllegalAccessException, InstantiationException {
        String helloWorld = new ByteBuddy()
                .subclass(Object.class)
                /** @see com.dyh.lvup.byteBuddy/HelloApp.java:22 **/
                /** {@link Hello}*/
                /** {@link com.dyh.lvup.byteBuddy/HelloApp.java:22}*/
                /** {@link Hello */
                .method(named("toString"))
                .intercept(FixedValue.value("Hello World!"))
                .make()
                .load(Hello.class.getClassLoader())
                .getLoaded()
                .newInstance()
                .toString();


        System.out.println(helloWorld);
    }
}
